﻿using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using Overload.Collections;

namespace Overload.Testing.Collections
{
    [TestFixture]
    public class PriorityQueueTesting
    {
        private PriorityQueue<string, int> queue;

        [SetUp]
        public void Setup()
        {
            queue = new PriorityQueue<string, int>();
            Assert.That(queue, Has.Count(0));
        }

        [Test]
        public void TestEnqueueing()
        {
            queue.Enqueue("Testing #1", 5);
            Assert.That(queue.Count, Is.EqualTo(1));

            queue.Enqueue("Testing #2", 12);
            Assert.That(queue.Count, Is.EqualTo(2));
        }

        [Test]
        public void TestDequeueing()
        {
            queue.Enqueue("Testing #1", 5);
            queue.Enqueue("Testing #2", 12);

            string dequeued = queue.Dequeue();

            Assert.That(queue.Count, Is.EqualTo(1));
            Assert.That(dequeued, Is.EqualTo("Testing #2"));
        }

        [Test]
        public void TestLargeQueue()
        {
            for(int i = 0; i < 10; i++)
                queue.Enqueue("Item " + i, i);

            for(int i = 9; i > 0; i--)
                Assert.That(queue.Dequeue(), Is.EqualTo("Item " + i));
        }
    }
}